using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class weapon : MonoBehaviour
{
    public float damage = -1;
    public int player = 1;
    public state state;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.L) && player == 1 || Input.GetKeyDown(KeyCode.Keypad3) && player == 2)
        {
            if (!gameObject.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).IsName("idle"))
            {
                return;
            }
            gameObject.GetComponent<Animator>().Play(Animator.StringToHash("hurt"));
            gameObject.GetComponent<BoxCollider2D>().enabled = true;
            state.isMovable = false;

        }
    }
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            collision.gameObject.GetComponent<playerControl>().hit(collision.gameObject, damage);
            gameObject.GetComponent<BoxCollider2D>().enabled = false;
        }
    }
    public void onWeaponFinished()
    {
        state.isMovable = true;

    }
}
